﻿package mortal.game.view.rebate.item
{
    import com.mui.controls.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.rebate.data.*;

    public class RebateTopPanel extends GSprite
    {
        protected var _bg:GImageBitmap;
        protected var _dayTip:GBitmap;
        protected var _sec:BitmapNumberText;
        protected var _min:BitmapNumberText;
        protected var _day:BitmapNumberText;
        protected var _hour:BitmapNumberText;
        protected var _activeTime:GTextFiled;
        protected var _actRule:GTextFiled;
        protected var _secView:SecTimerView;

        public function RebateTopPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            this._dayTip = UIFactory.gBitmap(ImagesConst.RebateDayTimeTip, 19, 147, this);
            this._day = UIFactory.bitmapNumberText(152, 143, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._day.text = "2";
            this._hour = UIFactory.bitmapNumberText(205, 143, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._hour.text = "23";
            this._min = UIFactory.bitmapNumberText(276, 143, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._min.text = "59";
            this._sec = UIFactory.bitmapNumberText(328, 143, "investmentNum.png", 24, 30, -8, this, 9, 0);
            this._sec.text = "59";
            this._secView = new SecTimerView();
            this._secView.addEventListener(EventName.SecViewTimeChange, this.onTimeChangeHd);
            this._activeTime = UIFactory.gTextField("" + Language.getString(71789), 15, 179, 430, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(13));
            this._actRule = UIFactory.gTextField("" + Language.getString(71790), 14, 197, 370, 25, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(13));
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._dayTip.dispose(param1);
            this._day.dispose(param1);
            this._hour.dispose(param1);
            this._min.dispose(param1);
            this._sec.dispose(param1);
            this._activeTime.dispose(param1);
            this._actRule.dispose(param1);
            this._dayTip = null;
            this._day = null;
            this._hour = null;
            this._min = null;
            this._sec = null;
            this._activeTime = null;
            this._actRule = null;
            this._secView.removeEventListener(EventName.SecViewTimeChange, this.onTimeChangeHd);
            this._secView.stop();
            this._secView.dispose();
            this._secView = null;
            return;
        }// end function

        protected function setTimeCountDown() : void
        {
            var _loc_1:* = this.getLeftTime();
            this._secView.stop();
            if (_loc_1 < 0)
            {
                return;
            }
            this._secView.setLeftTime(_loc_1);
            return;
        }// end function

        protected function getLeftTime() : Number
        {
            return RebateUtil.getTodayLeftTime();
        }// end function

        protected function onTimeChangeHd(event:DataEvent) : void
        {
            if (this._secView == null)
            {
                return;
            }
            if (this._secView.secTimerViewData == null)
            {
                this._secView.stop();
                return;
            }
            var _loc_2:* = this._secView.secTimerViewData.dd();
            var _loc_3:* = this._secView.secTimerViewData.hh();
            var _loc_4:* = this._secView.secTimerViewData.mm();
            var _loc_5:* = this._secView.secTimerViewData.ss();
            if (_loc_2.length == 2 && _loc_2 == "0")
            {
                _loc_2 = _loc_2.substring(1);
            }
            this._day.text = "" + _loc_2;
            this._hour.text = "" + _loc_3;
            this._min.text = "" + _loc_4;
            this._sec.text = "" + _loc_5;
            return;
        }// end function

    }
}
